package com.fjw.mapper;

import com.fjw.pojo.Result;
import com.fjw.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper//标明我是数据持久层MAPPER
public interface UserMapper {

    //注册
    @Insert("insert into User(username,password,role,gender,introduction) values (#{username},#{password},#{role},#{gender},#{introduction})")
    void regist(User user);

    // 注册用户
    @Insert("INSERT INTO User (username, password, role, gender, introduction) VALUES (#{username}, #{password}, #{role}, #{gender}, #{introduction})")
    void register(User user);

    //通过用户名查找
    @Select("select * from User where username=#{username}")
    User findByUsername(String username);

    //获取用户信息
    @Select("select * from User where id=#{id}")
    User findById(Integer id);

    //通过ID修改用户信息(除密码)
    @Update("update User set username=#{username},role=#{role},gender=#{gender},introduction=#{introduction} where id=#{id}")
    void updateById(User user);

    //通过ID修改密码
    @Update("update User set password=#{password} where id=#{id}")
    void updatePassword(Integer id,String password);

}
